//
//  TenderBaseTableController.swift
//  SlaughterClient
//
//  Created by 邱仙凯 on 2020/2/6.
//  Copyright © 2020 zwb. All rights reserved.
//

import UIKit

class TenderBaseTableController: UITableViewController {
    lazy var slideV:SlideView = {
        let v = SlideView(frame: CGRect(x:0,y:0,width: KSGlobal.screenW,height: KSGlobal.screenH), arr: [SlideContent(type: .singleSelect, title: "状态",dataArr:zhuangtaiArr_jp.map{ SeString(title: $0, ks_selected: ($0 == "全部")) },numberOfRow: 3,open: true),SlideContent(type: .singleSelect, title: "时间",dataArr: ["全部", "3日内", "7日内", "1月内", "3月内"].map{ SeString(title: $0, ks_selected: ($0 == "全部")) },numberOfRow: 3,open: true),SlideContent(type: .actionClo,title: "区域", inputStr: "全部",actionClo: { cuIndex in
            
            let vc = ProvinceCityController(selectType: .city)
            vc.citySelectClosure = { province,city in
            
                self.slideV.arr[2].inputStr = city
                self.slideV.tableView.reloadData()
            }
            let window = UIApplication.shared.keyWindow!.rootViewController!
            let nav = BaseNavigationController()
            nav.viewControllers = [vc]
            window.present_FullScreen(to: nav)
        
            
        })])
        return v
    }()
    var helper = ZyaTenderHelper()
    override func viewDidLoad() {
        super.viewDidLoad()

        tableView.rowHeight = UITableView.automaticDimension
        tableView.estimatedRowHeight = 90
        
        
        self.slideV.confirmClosure = { arr in
            
            let ss1 = arr[0].dataArr!.filter{ $0.ks_selected }
            if ss1.count > 0 {
                self.helper.filterPa!.zStatus = zhuangtaiDic_jp[ss1.first!.title]!
              } else {
                self.helper.filterPa!.zStatus = ""
                
            }
            
             
            
            
            let ss = arr[1].dataArr!.filter{ $0.ks_selected }
            if ss.count > 0 {
                 if ss.first!.title == "全部" {
                    self.helper.filterPa!.startDate = ""
                    self.helper.filterPa!.endDate = ""
                        
                    } else if ss.first!.title == "3日内" {
                        self.helper.filterPa!.startDate = Date.todayPres(3)
                        self.helper.filterPa!.endDate = Date.today
                        
                    } else if ss.first!.title == "7日内" {
                        self.helper.filterPa!.startDate = Date.todayPres(7)
                        self.helper.filterPa!.endDate = Date.today
                        
                    } else if ss.first!.title == "1月内" {
                        self.helper.filterPa!.startDate = Date.preMonthsWithNowday(1)
                        self.helper.filterPa!.endDate = Date.today
                        
                    } else if ss.first!.title == "3月内" {
                        self.helper.filterPa!.startDate = Date.preMonthsWithNowday(3)
                        self.helper.filterPa!.endDate = Date.today
                    }
              } else {
                self.helper.filterPa!.startDate = ""
                self.helper.filterPa!.endDate = ""
            }
         
            
           let city = arr[2].inputStr

            if city == "全部" {
                self.helper.filterPa!.zCity = ""
            } else {
                self.helper.filterPa!.zCity = city
            }
           
            
            self.slideV.close()
            self.tableView.mj_header?.beginRefreshing()
        }
    }
 

   

}
// -- 招投标备注
//  竞拍单据状态 ： z_status   0 未开始  【 1 已成交】  2 进行中 3 已结束  4 已流拍
//  竞拍出价状态 ：     已成交     未成交

